﻿function Window() {
	this.winName="newWin";
	this.width=600;
	this.height=400;
	this.top=0;
	this.left=0;
	this.ToolBar;
	this.Menubar;
	this.Scrollbars;	
	this.Resizable;
	this.Location;
	this.Status;
	this.OpenWin=OpenWin;
	this.OpenModal=OpenModal;
	
	/*
	ShowAlign有以下字元村
	NoAlign,
	Center,
	TopLeft,
	TopRight,
	BottomLeft,
	BottomRight*/
	this.ShowAlign="NoAlign";	
	
	function OpenWin(Url)
	{
		var property="height="+this.height+",width="+this.width;		
		swidth = screen.width;
		sheight= screen.availHeight;	
		if(this.ShowAlign!="NoAlign")
		{		

			if(this.ShowAlign=="Center")
			{
				this.top=(sheight-this.height)/2;
				this.left=(swidth-this.width)/2;
			}
			if(this.ShowAlign=="BottomLeft" || this.ShowAlign=="BottomRight")
			{
				this.top=(sheight-this.height-25*3);
			}
			
			if(this.ShowAlign=="TopLeft" || this.ShowAlign=="TopRight")
			{
				this.top;
			}
			
			if(this.ShowAlign=="TopLeft" || this.ShowAlign=="BottomLeft")
			{
				this.left=0;
			}
			
			if(this.ShowAlign=="TopRight" || this.ShowAlign=="BottomRight")
			{
				this.left=swidth-this.width;
			}			
		}
		
			
		if(this.top!=0)
			property+=",top="+this.top;
		if(this.left!=0)
			property+=",left="+this.left;

		//ToolBar
		if(this.ToolBar)
			property+=",toolbar=yes";
		else
			property+=",toolbar=no";			
		//MenuABar
		if(this.Menubar)
			property+=",menubar=yes";
		else
			property+=",menubar=no";
		
		if(this.Resizable)			
			property+=",resizable=yes";
		else
			property+=",resizable=no";		
		
		if(this.Location)			
			property+=",location=yes";
		else
			property+=",location=no";		
		
		if(this.Status)
			property+=",status=yes";
		else
			property+=",status=no";
		window.open(Url,this.winName,property);
	}
	function OpenModal(Url,currentWindow) {
		property="";
		if(this.width!=0)
			property="dialogWidth:"+this.width+"px;";
		if(this.height!=0)
			property+="dialogHeight:"+this.height+"px;";
		if(this.Scrollbars)			
			property+="scroll:yes;";
		else
			property+="scroll:no;";
		if(this.Status)
			property+="status:yes";
		else
			property+="status:no;center:yes'";
		var result=window.showModalDialog(Url,currentWindow,property);
		return result;
	}
}
